﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Cwing.UI.Validation
{
    [TypeConverter(typeof(ValidationResultConverter))]
    public class ValidationResult
    {
        private static ValidationResult empty;

        static ValidationResult()
        {
            empty = new ValidationResult();
            empty.Message = String.Empty;
            empty.Result = true;
            empty.isEmpty = true;
        }

        private Boolean isEmpty = false;

        public Boolean IsEmpty
        {
            get
            {
                return isEmpty;
            }
        }

        private Boolean result = true;

        public Boolean Result
        {
            get
            {
                return result;
            }
            set
            {
                if (IsEmpty)
                {
                    throw new Exception("This object is Static, This Property Can't be changed.");
                }
                else
                {
                    result = value;
                }
            }
        }

        private String message = String.Empty;

        public String Message
        {
            get
            {
                return message;
            }
            set
            {
                if (IsEmpty)
                {
                    throw new Exception("This object is Static, This Property Can't be changed.");
                }
                else
                {
                    message = value;
                }
            }
        }

        public static ValidationResult Empty
        {
            get
            {
                return empty;
            }
        }
    }
}
